﻿using System.Collections.ObjectModel;
using MusicExplorer.WebRepository;
using System.Windows.Media.Imaging;
using MusicExplorer.Resources.Images;
using GalaSoft.MvvmLight;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using MusicExplorer.ViewModel;

namespace MusicExplorer.Wrappers
{
    public class WebRepositoryWrapper : ViewModelBase
    {
        private readonly WebRepositoryBase m_webRepository;

        private readonly MainWindowViewModel m_parent;
        public MainWindowViewModel Parent { get { return m_parent; } }

        public WebRepositoryWrapper(MainWindowViewModel parent, WebRepositoryBase webRepository)
        {
            m_parent = parent;

            m_webRepository = webRepository;
            m_groups = new ObservableCollection<DetailTreeItemWrapper>();
            m_artists = new ObservableCollection<DetailTreeItemWrapper>();
        }

        private ObservableCollection<DetailTreeItemWrapper> m_groups;
        public ObservableCollection<DetailTreeItemWrapper> Groups
        {
            get { return m_groups; }
            set
            {
                if(m_groups != value)
                {
                    m_groups = value;
                    RaisePropertyChanged("Groups");
                }
            }
        }

        private ObservableCollection<DetailTreeItemWrapper> m_artists;
        public ObservableCollection<DetailTreeItemWrapper> Artists
        {
            get { return m_artists; }
            set
            {
                if (m_artists != value)
                {
                    m_artists = value;
                    RaisePropertyChanged("Artists");
                }
            }
        }

        private bool m_isLoading;
        public bool IsLoading
        {
            get { return m_isLoading; }
            set
            {
                if (m_isLoading != value)
                {
                    m_isLoading = value;
                    RaisePropertyChanged("IsLoading");
                }
            }
        }

        public WebRepositoryBase WebRepository { get { return m_webRepository; } }

        public string DisplayName { get { return m_webRepository.WebRepository.web_repo_name; } }

        public BitmapImage DisplayIcon { get { return Images.GetIcon(m_webRepository.WebRepository.web_repo_key); } }

        private bool m_isSelected;
        public bool IsSelected
        {
            get { return m_isSelected; }
            set
            {
                if (m_isSelected != value)
                {
                    m_isSelected = value;
                    RaisePropertyChanged("IsSelected");
                }
            }
        }
    }
}
